package at.dl.android.dota.adviser;

import android.content.Intent;

public class CallActivityImageAdapter extends SimpleImageAdapter {
    final protected ActivityWithDB currentAvticity;
    final private Class targetActivityClass;
    final private String keyParamName;

    CallActivityImageAdapter ( ActivityWithDB currentAvticity, 
                               Class targetActivityClass, 
                               String keyParamName, 
                               int[] ids, 
                               String[] names ) {
        super(currentAvticity,ids,names);
        this.currentAvticity = currentAvticity;
        this.targetActivityClass = targetActivityClass;
        this.keyParamName = keyParamName;
    }
    
    @Override
    protected void handleSelectedName ( CharSequence text ) {
        if ( targetActivityClass == null ) {
            super.handleSelectedName(text);
            return;
        }
        currentAvticity.onPause();
        Intent myIntent = new Intent(context,targetActivityClass);
        myIntent.putExtra(keyParamName,text);
        currentAvticity.startActivity(myIntent);
    }
}
